<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8"/>
        <title>000</title>
        <script>
            window.onload = function () {
                var oBtn = document.getElementById("btn");
                var aIpt = document.getElementsByTagName("input");
                var setTime = new Date("july 11,2018 01:16:30");
                aIpt[0].value = setTime;
                var timer = null;
                

                oBtn.onclick = function () {
                    function aa() {
                        var nowTime = new Date();
                        var t = Math.floor((setTime - nowTime)/1000);
                        if(t>=0) {
                            var str = Math.floor(t/86400)+ "天"+ Math.floor(t%86400/3600)+ "小时" + Math.floor(t%86400%3600/60)+"分钟"+ t%60+ "秒";
                            aIpt[1].value = str;
                        }else {
                            clearInterval(timer);
                        }
                    };
                    aa();
                    timer = setInterval( aa,1000 )
                }
            }
        </script>
    </head>
    <body>
        设定时间：<input type="text" value="july 10,2017 15:50:0" class="one"/>
        剩余时间：<input type="text" value="" class="one"/>
        <input type="button" value="开始计时" id="btn"/>
    </body>
</html>